%%function drawCurve2(Training, ControlTraining, Control,plot_pre_t_f,plot_post_t_f,plot_pre_t_n,plot_post_t_n,plot_pre_ct_f,plot_post_ct_f,plot_pre_ct_n,plot_post_ct_n,plot_pre_c_f,plot_post_c_f,plot_pre_c_n,plot_post_c_n)

colors = [2 158 154; 255 189 7; 211 57 33]/255;
m_t_pre_f = mean(plot_pre_t_f);
m_t_post_f = mean(plot_post_t_f);
m_t_pre_n = mean(plot_pre_t_n);
m_t_post_n = mean(plot_post_t_n);

index = [1,3:8];
plot_pre_ct_f = plot_pre_ct_f(index,:);
plot_post_ct_f = plot_post_ct_f(index,:);
plot_pre_ct_n = plot_pre_ct_n(index,:);
plot_post_ct_n = plot_post_ct_n(index,:);

m_ct_pre_f = mean(plot_pre_ct_f);
m_ct_post_f = mean(plot_post_ct_f);
m_ct_pre_n = mean(plot_pre_ct_n);
m_ct_post_n = mean(plot_post_ct_n);


m_c_pre_f = mean(plot_pre_c_f);
m_c_post_f = mean(plot_post_c_f);
m_c_pre_n = mean(plot_pre_c_n);
m_c_post_n = mean(plot_post_c_n);


se_t_pre_f = std(plot_pre_t_f)/sqrt(8);
se_t_post_f = std(plot_post_t_f)/sqrt(8);
se_t_pre_n = std(plot_pre_t_n)/sqrt(8);
se_t_post_n = std(plot_post_t_n)/sqrt(8);

se_ct_pre_f = std(plot_pre_ct_f)/sqrt(7);
se_ct_post_f = std(plot_post_ct_f)/sqrt(7);
se_ct_pre_n = std(plot_pre_ct_n)/sqrt(7);
se_ct_post_n = std(plot_post_ct_n)/sqrt(7);


se_c_pre_f = std(plot_pre_c_f)/sqrt(8);
se_c_post_f = std(plot_post_c_f)/sqrt(8);
se_c_pre_n = std(plot_pre_c_n)/sqrt(8);
se_c_post_n = std(plot_post_c_n)/sqrt(8);
% Subtraction positive means increased sensitivity
sub_t_f = plot_post_t_f-plot_pre_t_f;
sub_ct_f = plot_post_ct_f-plot_pre_ct_f;
sub_c_f = plot_post_c_f-plot_pre_c_f;

sub_t_n = plot_post_t_n-plot_pre_t_n;
sub_ct_n = plot_post_ct_n-plot_pre_ct_n;
sub_c_n = plot_post_c_n-plot_pre_c_n;

ms_t_f = mean(sub_t_f); ms_t_n = mean(sub_t_n);
ms_ct_f = mean(sub_ct_f); ms_ct_n = mean(sub_ct_n);
ms_c_f = mean(sub_c_f); ms_c_n = mean(sub_c_n);

ses_t_f = std(sub_t_f)/sqrt(8); ses_t_n = std(sub_t_n)/sqrt(8);
ses_ct_f = std(sub_ct_f)/sqrt(7); ses_ct_n = std(sub_ct_n)/sqrt(7);
ses_c_f = std(sub_c_f)/sqrt(8); ses_c_n = std(sub_c_n)/sqrt(8);

logfrequency = log(Training.pre_plot{1,1}(:,1));
figure('color',[1 1 1])
drawQCSF(logfrequency,plot_pre_t_n,plot_post_t_n,1,1);
set(gca, 'Linewidth',1);
drawQCSF(logfrequency,plot_pre_ct_n,plot_post_ct_n,2,1);
set(gca, 'Linewidth',1);
drawQCSF(logfrequency,plot_pre_c_n,plot_post_c_n,3,1);
set(gca, 'Linewidth',1);
set(gcf,'units','centimeters','position',[0 0 19 9])
figure('color',[1 1 1])
drawQCSF(logfrequency,plot_pre_t_f,plot_post_t_f,1,2);
set(gca, 'Linewidth',1);
drawQCSF(logfrequency,plot_pre_ct_f,plot_post_ct_f,2,2);
set(gca, 'Linewidth',1);
drawQCSF(logfrequency,plot_pre_c_f,plot_post_c_f,3,2);
set(gca, 'Linewidth',1);
set(gcf,'units','centimeters','position',[0 0 19 9])